package bear.download;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class Searchread extends DefaultHandler {
	String seaechloushiid,seaechloushiname,seaechloushicount,seaechloushicategory,createuser;
	public static int n;
	String tagName;
	public static String seaechloushiid1="",seaechloushiname1="",seaechloushicount1="",seaechloushicategory1="",createuser1="";
	public void startDocument() throws SAXException {
		//System.out.println("````````begin````````");
		n=0;
	}

	public void endDocument() throws SAXException {
		//System.out.println("````````end````````");
		//System.out.println(n);
	}

	public void startElement(String namespaceURI, String localName,
			String qName, Attributes attr) throws SAXException {
		tagName = localName;
		if (localName.equals("searchitem")) {
				//获取标签的全部属性
				for (int i = 0; i < attr.getLength(); i++) {
					//id1=id1+attr.getValue(i)+"$";
			}			
		}
	}

	public void endElement(String namespaceURI, String localName, String qName)
			throws SAXException {
		//在worker标签解析完之后，会打印出所有得到的数据
		tagName = "";
		if (localName.equals("searchitem")) {
			printout();
			n++;
		}
	}

	public void characters(char[] ch, int start, int length)
			throws SAXException {
		if (tagName.equals("searchid"))
			seaechloushiid= new String(ch, start, length);
		else if (tagName.equals("searchname"))
			seaechloushiname = new String(ch, start, length);
		else if (tagName.equals("searchcount"))
			seaechloushicount = new String(ch, start, length);
		else if (tagName.equals("searchcategory"))
			seaechloushicategory = new String(ch, start, length);
		else if (tagName.equals("searchcreateuser"))
			createuser = new String(ch, start, length);
	}

	public void printout() {
		seaechloushiid1=seaechloushiid1 + seaechloushiid +"$";
		seaechloushiname1=seaechloushiname1 +seaechloushiname +"$";
		seaechloushicount1=seaechloushicount1+seaechloushicount+"$";
		seaechloushicategory1=seaechloushicategory1+seaechloushicategory+"$";
		createuser1=createuser1+createuser+"$";
	}
}
